package n03;

import java.util.Arrays;

public class F01 {
	public static void main(String[] args) {
		String s="What you see is what you get";
		System.out.println(s);
		System.out.println(s.length());//获取字符串的长度
		System.out.println(s.charAt(0));//获取索引0处的字符
		System.out.println(s.codePointAt(0));//获取索引0处的字符代码点，就是Unicode值
		System.out.println(s.indexOf("you"));//从前往后搜索you，返回首次找到的位置，-1没有找到
		System.out.println(s.indexOf("you",10));//同上，从索引10开始查找
		System.out.println(s.lastIndexOf("you"));//同上，从后往前搜索you 
		System.out.println(s.substring(21));//取索引21开始到最后的所有内容
		System.out.println(s.substring(0,2));//取两个索引间的内容，含起始索引，不含结束索引
		System.out.println(s.toLowerCase());//转换为小写
		System.out.println(s.toUpperCase());//转换为大写
		System.out.println(s.startsWith("What"));//是否以What开头
		System.out.println(s.endsWith("get"));//是否以get结尾
		System.out.println(Arrays.toString(s.split(" ")));//字符串分割为字符串数组
		System.out.println(String.join("-=-", "How","are","you"));//多个字符串拼接
		System.out.println("\t How are you?\n\t ".trim());//删除字符串前后的空白
		System.out.println("\t How are you? \t ".replace("\t", "*"));//字符串替换
		System.out.println("\t How are you?\n\t ".replaceAll("\\s+", "*"));//字符串正则替换
		System.out.printf("字符串：[%8s], [%-6s], [%.4s]\n","Right","Left","Truncation");
		System.out.print(String.format("%d + %d = %d\n", 111,234,111+234));//按格式返回字符串
		
		
	}
}
